Type Classes with Existential Types

نویسنده

  • Konstantin Läufer
چکیده

We argue that the novel combination of type classes and existential types in a single language yields significant expressive power. We explore this combination in the context of higher-order functional languages with static typing, parametric polymorphism, algebraic data types, and Hindley-Milner type inference. Adding existential types to an existing functional language that already features type classes requires only a minor syntactic extension. We first demonstrate how to provide existential quantification over type classes by extending the syntax of algebraic data type definitions and give examples of possible uses. We then develop a type system and a type inference algorithm for the resulting language. Finally, we present a formal semantics by translation to an implicitly-typed second-order λ-calculus and show that the type system is semantically sound. Our extension has been implemented in the Chalmers Haskell B. system, and all examples from this paper have been developed using this system.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Framework for Extended Algebraic Data Types

Data Types have Existential Types data Stack a = forall s. Stack s -self (a->s->s) -push (s->s) -pop (s->a) -top (s->Bool) -empty push :: a -> Stack a -> Stack a push x (Stack s push’ pop top empty) = Stack (push’ x s) push’ pop top empty pop :: Stack a -> Stack a pop (Stack s push pop’ top empty) = Stack (pop’ s) push pop’ top empty A Framework for Extended Algebraic Data Types – p.6 Abstract ...

متن کامل

Combining Type Classes and Existential Types

This paper demonstrates that the novel combination of type classes and existential types adds significant expressive power to a language, requiring only a minor syntactic change. We explore this combination in the context of higher-order functional languages with static typing, parametric polymorphism, algebraic data types, and Hindley-Milner type inference. Since we have examined the underlyin...

متن کامل

JavaGI : Generalized Interfaces for Java

JavaGI is an experimental language that extends Java 1.5 by generalizing the interface concept to incorporate the essential features of Haskell’s type classes. In particular, generalized interfaces cater for retroactive and constrained interface implementations, binary methods, static methods in interfaces, default implementations for interface methods, interfaces over families of types, and ex...

متن کامل

A Type System for Computer Algebra

This paper presents a type system for support of subtypes, parameterized types with sharing and categoriesin a computeralgebra environment.By modelingrepresentationof instances in terms of existential types, we obtain a simpliied model, and build a basis for deening subtyping among algebraic domains. The inheritance at category level has been formalized; this allows the automatic inference of t...

متن کامل

Programming with Structures, Functions, and Objects | Updated Version |

We describe program structuring mechanisms for integrating algebraic, functional and object-oriented programming in a single framework. Our language is a statically typed higher-order language with speciications, structures, types, and values, and with universal and existential abstraction over structures, types, and values. We show that existential types over structures generalize both the nec...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • J. Funct. Program.

دوره 6  شماره 

صفحات  -

تاریخ انتشار 1996